﻿using LJX.SmartPark.Common.Extensions;
using LJX.SmartPark.Common.ResponseOutput;
using LJX.SmartPark.Domain.AssetManage;
using LJX.SmartPark.Domain.ParkManage;
using LJX.SmartPark.Service.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LJX.SmartPark.Service.ParkManage
{
    public class BlackListService: IBlackListService
    {
        private readonly IRepository<BlackList> _BlackListService;

        public BlackListService(IRepository<BlackList> BlackListService)
        {
            _BlackListService = BlackListService;
        }

        public async Task<Response<List<BlackList>>> GetBlackListPage(BlackListSelect select)
        {
            var datas = await _BlackListService.GetAllListAsync();
            var result = datas.MapToList<BlackList>();
            var totalCount = result.Count();

            result = result.Skip(((select.pageIndex - 1) * select.pageSize)).Take(select.pageSize).ToList();

            return Response<List<BlackList>>.Ok(result, totalCount);
        }


        public int GetCount()
        {
            return _BlackListService.GetCount();
        }

        public class BlackListSelect
        {
            public int pageIndex { get; set; }
            public int pageSize { get; set; }
        }
    }
}
